﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace aaaa
{
    public partial class BJSel : Form
    {
        public BJSel()
        {
            InitializeComponent();
        }

        private void BJSel_Load(object sender, EventArgs e)
        {
            string sql = "select bjname from classtest";
            SqlOperate onj = new SqlOperate();
            SqlDataReader read = onj.getDataReader(sql);
            while (read.Read())
            {
                comboBox1.Items.Add(read.GetValue(0).ToString());
            }
            comboBox1.SelectedIndex = 0;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string sql = "Select * from classtest where bjname ='"+comboBox1.Text+"'";
            SqlOperate obj = new SqlOperate();

            obj.getDataBind(dataGridView1, sql);   //将查询列 放入dataGridView1 中；

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string sql = "Select * from classtest ";
            SqlOperate obj = new SqlOperate();

            obj.getDataBind(dataGridView1, sql);   //将查询列 放入dataGridView1 中；
        }
    }
}
